﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using NHibernate;
using log4net;
using Wanet.PublicPortal.Common.Utilities;

namespace Wanet.PublicPortal.Common.Managers
{
	public abstract class BaseManager
	{
		private ISession _session = null;
		private ILog _log = null;

		/// <summary>
		/// Gets the current session of the persistence objects.
		/// </summary>
		/// <value>The session.</value>
		public ISession Session
		{
			get
			{
				if (_session == null)
				{
					_session = HibernateHelper.GetCurrentSession();
				}

				return _session;
			}
		}

		/// <summary>
		/// Gets the log instance to support logging.
		/// </summary>
		/// <value>The log.</value>
		public ILog Log
		{
			get
			{
				if (_log == null)
				{
					_log = Logging.GetLogger(this.GetType());
				}

				return _log;
			}
		}
	}
}
